﻿using BCCommon;
using BCDto.TMS.MoveHouseConfig.MoveHouseSpecificationConfig;
using BCDto.TMS.MoveHouseConfig.MoveHouseSpecificationConfig.MoveHouseSpecificationConfigRequest;
using BCService.TMS.MoveHouseConfig.MoveHouseConfig;
using BCService.TMS.MoveHouseConfig.MoveHouseSpecificationConfig;
using BCTMSRESTful.Configs;
using BCTMSRESTful.Controllers.Management;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace BCTMSRESTful.Controllers.Management.TMS.MoveHouseConfig
{
    /// <summary>
    /// 搬家规格设置
    /// </summary>
    [Route("api/v1/sim/[controller]")]
    [ApiExplorerSettings(GroupName = "TMSAdmin")]
    public class MoveHouseSpecificationConfigController : ManagementBaseController
    {
        private readonly IMoveHouseSpecificationConfigService moveHouseSpecificationConfigService;
        public MoveHouseSpecificationConfigController(IMoveHouseSpecificationConfigService moveHouseSpecificationConfigService)
        {
            this.moveHouseSpecificationConfigService = moveHouseSpecificationConfigService;
        }

        /// <summary>
        /// 创建搬家规格配置
        /// </summary>
        /// <param name="moveHouseConfigId">搬家配置id</param>
        /// <param name="requestDto">搬家规格配置</param>
        /// <response code="201">创建优惠券。</response>
        /// <returns></returns>
        [HttpPost("{move_house_config_id}")]
        [Log("创建搬家规格配置")]
        [ProducesResponseType(typeof(MoveHouseSpecificationConfigDto), 200)]
        public IActionResult Create([FromRoute(Name = "move_house_config_id")] long moveHouseConfigId,
            [FromBody] MoveHouseSpecificationConfigRequestDto requestDto)
        {
            var result = this.moveHouseSpecificationConfigService.Create(moveHouseConfigId, requestDto, this.Admin);
            return this.Ok(result);
        }

        /// <summary>
        /// 修改搬家规格配置
        /// </summary>
        /// <param name="moveHouseSpecificationConfigId">搬家规格配置id</param>
        /// <param name="requestDto">搬家规格配置</param>
        /// <response code="201">修改搬家规格配置。</response>
        /// <returns></returns>
        [HttpPut("{move_house_specification_config_id}")]
        [Log("修改搬家规格配置")]
        [ProducesResponseType(typeof(bool), 200)]
        public IActionResult Update([FromRoute(Name = "move_house_specification_config_id")] long moveHouseSpecificationConfigId,
            [FromBody] MoveHouseSpecificationConfigRequestDto requestDto)
        {
            var result = this.moveHouseSpecificationConfigService.Update(moveHouseSpecificationConfigId, requestDto, this.Admin);
            return this.Ok(result);
        }

        /// <summary>
        /// 获取单个搬家规格配置信息
        /// </summary>
        /// <param name="moveHouseSpecificationConfigId">搬家规格配置id</param>
        /// <returns></returns>
        [HttpGet("{move_house_specification_config_id}")]
        [ProducesResponseType(typeof(MoveHouseSpecificationConfigDto), 200)]
        public IActionResult GetSingle([FromRoute(Name = "move_house_specification_config_id")] long moveHouseSpecificationConfigId)
        {
            var result = this.moveHouseSpecificationConfigService.GetSingle(this.Admin, moveHouseSpecificationConfigId);
            return this.Ok(result);
        }

        /// <summary>
        /// 获取搬家规格配置列表(点击二类调用此接口-非全部--isall=false)
        /// </summary>
        /// <param name="moveHouseConfigId">搬家配置id</param>
        /// <param name="isEnable">是否可用</param>
        /// <returns></returns>
        [HttpGet("[action]/{move_house_config_id}")]
        [ProducesResponseType(typeof(IEnumerable<MoveHouseSpecificationConfigDto>), 200)]
        public IActionResult GetList([FromRoute(Name = "move_house_config_id")] long moveHouseConfigId,
            [FromQuery(Name = "is_enable")] bool? isEnable
            )
        {
            var result = this.moveHouseSpecificationConfigService.GetList(this.Admin, moveHouseConfigId, isEnable);
            return this.Ok(result);
        }


        /// <summary>
        /// 获取所有搬家规格配置列表(点击二类调用此接口--全部--isall=true)
        /// </summary>
        /// <param name="moveHouseConfigId">搬家配置id</param>
        /// <param name="isEnable">是否可用</param>
        /// <returns></returns>
        [HttpGet("[action]/{move_house_config_id}")]
        [ProducesResponseType(typeof(IEnumerable<MoveHouseSpecificationConfigDto>), 200)]
        public IActionResult GetAllList([FromRoute(Name = "move_house_config_id")] long moveHouseConfigId,
            [FromQuery(Name = "is_enable")] bool? isEnable
            )
        {
            var result = this.moveHouseSpecificationConfigService.GetAllList(this.Admin, moveHouseConfigId, isEnable);
            return this.Ok(result);
        }
        /// <summary>
        /// 删除规格配置
        /// </summary>
        /// <param name="moveHouseSpecificationConfigId">搬家规格配置id</param>
        /// <response code="201">删除规格配置。</response>
        /// <returns></returns>
        [HttpDelete]
        [Log("删除规格配置")]
        [ProducesResponseType(typeof(bool), 200)]
        public IActionResult Delete([FromQuery(Name = "move_house_specification_config_id")] long moveHouseSpecificationConfigId)
        {
            var result = this.moveHouseSpecificationConfigService.Delete(moveHouseSpecificationConfigId, this.Admin);
            return this.Ok(result);
        }

        /// <summary>
        /// 修改搬家规格配置是否可用
        /// </summary>
        /// <param name="moveHouseSpecificationConfigId">搬家规格配置id</param>
        /// <param name="enabled">是否可用</param>
        /// <response code="201">修改搬家规格配置是否可用。</response>
        /// <returns></returns>
        [HttpPut("[action]/{move_house_specification_config_id}/{enabled}")]
        [Log("修改搬家规格配置是否可用")]
        [ProducesResponseType(typeof(NoContentResult), 204)]
        public IActionResult Enabled([FromRoute(Name = "move_house_specification_config_id")] long moveHouseSpecificationConfigId,
            [FromRoute(Name = "enabled")] bool enabled)
        {
            if (enabled)
                this.moveHouseSpecificationConfigService.Enabled(moveHouseSpecificationConfigId,this.Admin);
            else
                this.moveHouseSpecificationConfigService.Disabled(moveHouseSpecificationConfigId,this.Admin);
            return NoContent();
        }
    }
}
